ordinary (1) | void operator delete (void* ptr) throw(); |
---|---|
nothrow (2) | void operator delete (void* ptr, const std::nothrow_t& nothrow_constant) throw(); |
placement (3) | void operator delete (void* ptr, void* voidptr2) throw(); |
ordinary (1) | void operator delete (void* ptr) noexcept; |
---|---|
nothrow (2) | void operator delete (void* ptr, const std::nothrow_t& nothrow_constant) noexcept; |
placement (3) | void operator delete (void* ptr, void* voidptr2) noexcept; |
ordinary (1) | void operator delete (void* ptr) noexcept; |
---|---|
nothrow (2) | void operator delete (void* ptr, const std::nothrow_t& nothrow_constant) noexcept; |
placement (3) | void operator delete (void* ptr, void* voidptr2) noexcept; |
with size (4) | void operator delete (void* ptr, std::size_t size) noexcept; |
nothrow with size (5) | void operator delete (void* ptr, std::size_t size, const std::nothrow_t& nothrow_constant) noexcept; |
::operator delete(ptr)
.::operator delete(ptr)
.operator delete
are declared in the global namespace, not within the std namespace.<new>
is included or not.operator delete
is a regular function that can be called explicitly just as any other function. But in C++, delete
is an operator with a very specific behavior: An expression with the delete
operator, first calls the appropriate destructor (for class types), and then calls a deallocation function.operator delete
, if it exists. In all other cases it is a global function operator delete
(i.e., this function -- or a more specific overload). If the delete
expression is preceded by the scope operator (i.e., ::operator delete
), only global deallocation functions are considered.delete
expressions that use global deallocation functions, always call single-argument signatures (such as (1)).delete
expressions that use global deallocation functions always use the signature that takes either a pointer (such as (1)), or a pointer and a size (such as (4)). Preferring always the version with size (4), unless an overload provides a better match for the pointer type.delete
operator always calls the ordinary version of this function, and exactly once for each of its arguments). These other signatures are only called automatically by a new-expression when their object construction fails (e.g., if the constructor of an object throws while being constructed by a new-expression with nothrow, the matching operator delete function accepting a nothrow argument is called).void*
.operator new
, and have not yet been released by a previous call to this function.operator new
, and have not yet been released by a previous call to this function.
|
|
MyClass constructed MyClass destroyed |